package com.ruoyi.settled.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.settled.domain.SalesOrders;
import com.ruoyi.settled.service.IBloggersOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import static com.ruoyi.common.utils.PageUtils.startPage;

/**
 * 订单管理Controller
 *
 * @author lzp
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/settled/order")
public class SalesOrdersController extends BaseController
{
    @Autowired
    private IBloggersOrderService salesOrderService;

    /**
     * 查询订单管理列表
     */

    @GetMapping("/list")
    public TableDataInfo list(SalesOrders salesOrder)
    {
        startPage();
        List<SalesOrders> list = salesOrderService.selectSalesOrderList(salesOrder);
        return getDataTable(list);
    }

    /**
     * 导出订单管理列表
     */


    @PostMapping("/export")
    public void export(HttpServletResponse response, SalesOrders salesOrders)
    {
        List<SalesOrders> list = salesOrderService.selectSalesOrderList(salesOrders);
        ExcelUtil<SalesOrders> util = new ExcelUtil<SalesOrders>(SalesOrders.class);
        util.exportExcel(response, list, "订单管理数据");
    }

    /**
     * 获取订单管理详细信息
     */

    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
    {
        return success(salesOrderService.selectSalesOrderByOrderId(orderId));
    }



    /**
     * 修改订单管理
     */
    @PutMapping
    public AjaxResult edit(@RequestBody SalesOrders salesOrder)
    {
        return toAjax(salesOrderService.updateSalesOrder(salesOrder));
    }


    /**
     * 获取博主订单
     */

    @GetMapping("/BloggerOrdersList")
    public TableDataInfo BloggerOrdersList(String businessType)
    {
        businessType="4";
        startPage();
        List<SalesOrders> list = salesOrderService.selectBloggerOrdersList(businessType);
        return getDataTable(list);
    }


}
